'Solar System Object Finder
'V1.0 11.02.2026
'Peter Doerwald
'need V6.02.00

Option BASE 1
Option Explicit
Const TRUE  = 1
Const FALSE = 0
Dim float lat    'negative if south
Dim float long   'negative if west
Dim integer zone 'UTC Timezone
Dim integer DST
Dim sidTime
Dim Sid$
Dim integer Music
Dim Musictype$  '"MP3" or "WAV"
Dim integer Zaehler
Dim utc$
Dim Abfrage$
Dim SONG$
Dim Status$="<D>ST[ ] <S>ettings <M>usic[ ] <Q>uit"
Dim alt,az
Dim solar$(9)=("SUN","MOON","MERCURY","VENUS","MARS","JUPITER","SATURN","URANUS","NEPTUNE")
Dim x%

If MM.Info(exists file "ObjectFinder04.ini") = TRUE Then
 Open "ObjectFinder04.ini" For Input As #1
 Input #1, lat, long, zone, DST, Music, SONG$, Musictype$
 Pause 500
 Close #1
Else
 CLS
 Print
 Print
 Print
 Print
 Print "     INF file does not exist:"
 SETTINGS
End If

'*** manipulate Status$ ***
If DST=FALSE Then
 MID$(Status$,7,1)=" "
Else
 MID$(Status$,7,1)="x"
End If

If Music=TRUE Then
 MID$(Status$,29,1)="x"
Else
 MID$(Status$,29,1)=" "
End If





CLS

Do

 If MM.Info(sound)="OFF" Then
  If Music=TRUE Then
   If Musictype$ = "mp3" Then
    Play mp3(SONG$+"."+Musictype$)
   Else
    Play wav(SONG$+"."+Musictype$)
   End If
  End If
 End If
 'calculate UTC
 UTC$ = DateTime$(Epoch(now)-zone*3600-DST*3600)
 Location utc$,lat,long,sidTime

 Text MM.HRES/2, 6, "** Zachzig presents **", "CM", 7, 1, RGB(BLUE)
 Text MM.HRES/2, 25, "Solar System Object Finder", "CM", 7, 2, RGB(CYAN)
 If MM.Info(PLATFORM)="PicoCalc" Then
  Text MM.HRES/2, 50, "UTC:"+utc$+" Bat:"+Str$(MM.Info(Battery))+"%  ", "CM", 1, 1, RGB(GREEN)
 Else
  Text MM.HRES/2, 50, "UTC:"+utc$+" Bat:", "CM", 1, 1, RGB(GREEN)
 EndIf
 Text MM.HRES/2-160, 57,Status$

 'calculate local sideral time
 Sid$="LST: "+Str$(Fix(sidTime),2,0,"0")+":"+Str$(Fix((sidtime-Fix(sidTime))*60),2,0,"0")
 Text MM.HRES/2-160, 72,Sid$

 Line 0,90,319,90,1,RGB(yellow)
 Text 95, 89,"Altitude", "LB", 2, 1, RGB(WHITE)
 Text 210, 89,"Azimuth", "LB", 2, 1, RGB(WHITE)

 For x%=1 To 9
  Text 0, x%*25+88,solar$(x%), "LB", 2, 1, RGB(YELLOW)
  Line 0,90+(x%*25),319,90+(x%*25),1,RGB(yellow)
  Execute "Astro "+solar$(x%)+" alt,az"

  If alt<0 Then
   Text 95, x%*25+88,Str$(alt,3,4), "LB", 2, 1, RGB(RED)
  Else
   Text 95, x%*25+88,Str$(alt,3,4), "LB", 2, 1, RGB(GREEN)
  EndIf
   Text 210, x%*25+88,Str$(az,3,4), "LB", 2, 1, RGB(GREEN)
 Next x%
 For Zaehler=1 To 1000 Step 100

  Abfrage$ = Inkey$
  If Abfrage$ <> "" Then
   Select Case Abfrage$

    Case "d", "D"
     If DST=FALSE Then
      DST=TRUE
      MID$(Status$,7,1)="x"
     Else
      DST=FALSE
      MID$(Status$,7,1)=" "
     End If

    Case "s", "S"
     CLS
     SETTINGS

    Case "m", "M"
     If Music=TRUE Then
      Play stop
      Music=FALSE
      MID$(Status$,29,1)=" "
     Else
      Music=TRUE
      MID$(Status$,29,1)="x"
     End If

    Case "q", "Q"
     CLS
     End

   End Select
  End If
 Next Zaehler
Loop

Sub Settings
 'CLS
 Text MM.HRES/2, 6, "** Zachzig presents **", "CM", 7, 1, RGB(BLUE)
 Text MM.HRES/2, 25, "Solar System Object Finder", "CM", 7, 2, RGB(CYAN)
 Print
 Print
 Print
 Print
 Print
 Do
  Print "LATITUDE"
  Input "(negative if south): ",lat
 Loop Until lat >= -90 And lat <= 90
 Print
 Do
  Print "LONGITUDE"
  Input "(negative if west) : ",long
 Loop Until long >= -180 And long <= 180
 Print
 Do
  Input "Timezone: ",zone
 Loop Until zone >= -11 And zone <= 11
 Print
 Do
  Print "Daylightsaving"
  Input "(1 = TRUE / 0 = FALSE): ",DST
 Loop Until DST >= 0 And DST <= 1
 Print
 Do
  Print "Play background music"
  Input "(1 = TRUE / 0 = FALSE): ",Music
 Loop Until Music >= 0 And Music <= 1
 Print
  Do
  Print "Background music type"
  Input "(MP3 or WAV): ",Musictype$
 Loop Until Musictype$>="MP3" Or Musictype$>="mp3" Or Musictype$>="WAV" Or Musictype$>="wav"
 Musictype$=LCase$(Musictype$)
 Print
 Do
  Print "Background song"
  Input "(without extension mp3 or wav): ",SONG$
 Loop Until (MM.Info(exists file(SONG$+"."+Musictype$))=TRUE)

 If MM.Info(exists file "ObjectFinder04.ini") = TRUE Then
  CLS
  Text MM.HRES/2, 6, "** Zachzig presents **", "CM", 7, 1, RGB(BLUE)
  Text MM.HRES/2, 25, "Solar System Object Finder", "CM", 7, 2, RGB(CYAN)
  Print
  Print
  Input "SAVE SETTINGS (J/N)";Abfrage$
  If Abfrage$="N" Or Abfrage$="n" Then
   CLS
   Exit Sub
  End If
 End If

 Open "ObjectFinder04.ini" For Output As #1
 Print #1, lat;",",long;",",zone;",",DST;",",Music;",",SONG$;",",Musictype$
 Pause 500
 Close #1
 CLS
End Sub
